package cn.dgut.training.dto.activity;

import cn.dgut.training.dto.BaseDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CouponUserDTO extends BaseDTO {

    private Long userId;

    private Integer status;

    private Long couponId;


    /**
     * 根据优惠券id查询
     * @param couponUserDTO
     * @return
     */
    public static QueryWrapper getWrapper(CouponUserDTO couponUserDTO){

        QueryWrapper queryWrapper=new QueryWrapper();


        if(couponUserDTO.getUserId()!=null){
            queryWrapper.eq("user_id",couponUserDTO.getUserId());
        }
        if(couponUserDTO.getStatus()!=null){
            queryWrapper.eq("status",couponUserDTO.getStatus());
        }
        if(couponUserDTO.getCouponId()!=null){
            queryWrapper.eq("coupon_id",couponUserDTO.getCouponId());
        }
        return queryWrapper;

    }

    /**
     * 根据用户id查询
     * @param userId
     * @return
     */
    public static QueryWrapper getWrapperByUserId(Long userId){

        QueryWrapper queryWrapper=new QueryWrapper();
        if(userId!=null){
            queryWrapper.eq("user_id",userId);
        }

        return queryWrapper;

    }
}
